package com.example.springboot.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.*;

import com.example.springboot.entity.Book;

import java.util.List;
@Mapper
public interface BookMapper extends BaseMapper<Book> {
    @Select("SELECT * from book")
    List<Book> findAll();
    @Insert("INSERT into book(ISBN,bname,author,price,inventory,tupian,introduction) " +
            "VALUES(#{ISBN},#{bname},#{author},#{price},#{inventory},#{tupian},#{introduction})")
    int insert(Book book);
    @Update("UPDATE book SET bname=#{bname},author=#{author},price=#{price}," +
            "inventory=#{inventory},tupian=#{tupian},introduction=#{introduction} WHERE ISBN=#{ISBN}")
    int update(Book book);
    @Delete("DELETE FROM book WHERE ISBN=#{ISBN}")
    Integer deleteByISBN(@Param("ISBN") Long ISBN);
    @Select("SELECT * FROM book WHERE ISBN=#{isbn}")
    List<Book> findByISBN(Long isbn);
    @Select("SELECT * FROM book WHERE author=#{author}")
    List<Book> findByAuthor(String author);
    @Select("SELECT * FROM book WHERE bname=#{bname}")
    List<Book> findByBname(String bname);
    @Update("UPDATE book SET inventory=#{inventory} WHERE ISBN=#{ISBN}")
    Integer updateNum(Book book);


}
